package cn.wp.common.core.module.log;

import cn.wp.common.core.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 访问日志服务
 * Created by chenyb on 2019/09/29
 */
@Service
public class AccessLogService {

    @Autowired
    private AccessLogDao accessLogDao;

    /**
     * 保存日志
     * 开启新事务
     */
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int saveLog(AccessLogDto accessLogDto){
        AccessLogDo accessLogDo = BeanUtil.copyProperties(accessLogDto,AccessLogDo.class);
        return accessLogDao.insert(accessLogDo);
    }

}
